package cn.com.xy.sms.sdk.service.baseparse;

import java.util.Map;
import java.util.concurrent.Callable;

import android.content.Context;
import cn.com.xy.sms.sdk.constant.Constant;
import cn.com.xy.sms.sdk.log.LogManager;
/*SDK-633 hewengao 20161009 start*/
import cn.com.xy.sms.sdk.threadpool.SmartSmsThreadPoolManager;
import android.os.Process;
/*SDK-633 hewengao 20161009 end*/
/* SDK-454 hewengao/20160523 start */
public class BaseParseCallable implements Callable<Map<String, Object>>{

	 Context ctx;
	 String phoneNumber;
	 String smsCenterNum;
	 String smsContent;
	 long smsTime;
	 Map<String, String> extend;
	 Thread thread =null;
	public void setParam(final Context ctx,final String phoneNumber, final String smsCenterNum,final String smsContent,final long smsTime, final Map<String, String> extend){
		this.ctx =ctx;
		this.phoneNumber= phoneNumber;
		this.smsCenterNum = smsCenterNum;
		this.smsContent = smsContent;
		this.smsTime=  smsTime;
		this.extend = extend;
	}
	@Override
	public Map<String, Object> call() throws Exception {
		// TODO Auto-generated method stub
		/*SDK-633 hewengao 20161009 start*/
		SmartSmsThreadPoolManager.setThreadNameAndPriority(SmartSmsThreadPoolManager.TNAME_BASEPARSE, Process.THREAD_PRIORITY_BACKGROUND);
		/*SDK-633 hewengao 20161009 end*/
		thread =Thread.currentThread();
		return BaseParseService.baseParseMsg(ctx, phoneNumber, smsCenterNum, smsContent, smsTime, extend);
	}
	public void destory(){
		this.ctx = null;
		this.phoneNumber = null;
		this.smsCenterNum = null;
		this.smsContent = null;
		this.smsTime = 0;
		this.extend =null;
		this.thread =null;
	}
	public void stopThread(){
		try{
			if(thread != null){
				thread.stop();
			}
		}catch (Throwable e) {
            /* SDK-559 huangzhiqiang 20160725 start */
            LogManager.w(Constant.TAG, "BaseParseCallable stopThread error ", e);
            /* SDK-559 huangzhiqiang 20160725 end */
        }
	}
}
/* SDK-454 hewengao/20160523 start */
